package com.hong.springboot.config;

import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: csh
 * @Date: 2021/2/2 10:36
 * @Description:
 */
@Configuration
public class MotanConfig {

    /**
     *
     * 功能描述: 声明Annotation用来指定需要解析的包名
     *
     * @param:
     * @return:
     * @auther: csh
     * @date: 2021/2/2 9:48
     */
    @Bean
    @ConfigurationProperties(prefix = "motan.annotation")
    public AnnotationBean motanAnnotationBean() {
        AnnotationBean motanAnnotationBean = new AnnotationBean();
        return motanAnnotationBean;
    }
    /**
     *
     * 功能描述: 配置ProtocolConfig、RegistryConfig、BasicServiceConfig的bean对象，功能与xml配置中的protocol、registry、basicService标签一致。
     *
     * @param:
     * @return:
     * @auther: csh
     * @date: 2021/2/2 9:48
     */
    @Bean(name = "demoMotan")
    @ConfigurationProperties(prefix = "motan.protocol")
    public ProtocolConfigBean protocolConfig1() {
        ProtocolConfigBean config = new ProtocolConfigBean();
        return config;
    }

    @Bean(name = "registryConfig")
    @ConfigurationProperties(prefix = "motan.registry")
    public RegistryConfigBean registryConfig() {
        RegistryConfigBean config = new RegistryConfigBean();
        return config;
    }

    @Bean
    @ConfigurationProperties(prefix = "motan.server")
    public BasicServiceConfigBean baseServiceConfig() {
        BasicServiceConfigBean config = new BasicServiceConfigBean();
        config.setExport("demoMotan:8086");
        config.setAccessLog(false);
        config.setShareChannel(true);
        return config;
    }
}
